﻿Imports System.Data
Imports System.Data.SqlClient
Imports Sistema_InformacionNaviera.BE
Imports Sistema_InformacionNaviera.DALC
Imports Sistema_InformacionNavier.UTIL



Public Class TarifaFleteDALC


    Public Function InsertarTarifaFlete(ByVal objTarifaFleteBE As TarifaFleteBE, ByRef bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim arrSqlParameter(23) As SqlParameter

        Try
            arrSqlParameter(0) = New SqlParameter()
            arrSqlParameter(0).ParameterName = "@TOPE"
            arrSqlParameter(0).SqlDbType = SqlDbType.Char
            arrSqlParameter(0).Size = 1
            arrSqlParameter(0).Direction = ParameterDirection.Input
            arrSqlParameter(0).Value = objTarifaFleteBE.TOPE

            arrSqlParameter(1) = New SqlParameter()
            arrSqlParameter(1).ParameterName = "@Tfl_Tipo"
            arrSqlParameter(1).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(1).Size = 10
            arrSqlParameter(1).Direction = ParameterDirection.Input
            arrSqlParameter(1).Value = objTarifaFleteBE.Tfl_Tipo

            arrSqlParameter(2) = New SqlParameter()
            arrSqlParameter(2).ParameterName = "@Tfl_Tmov"
            arrSqlParameter(2).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(2).Size = 1
            arrSqlParameter(2).Direction = ParameterDirection.Input
            arrSqlParameter(2).Value = objTarifaFleteBE.Tfl_Tmov

            arrSqlParameter(3) = New SqlParameter()
            arrSqlParameter(3).ParameterName = "@Tfl_Fivig"
            arrSqlParameter(3).SqlDbType = SqlDbType.Date
            arrSqlParameter(3).Direction = ParameterDirection.Input
            arrSqlParameter(3).Value = objTarifaFleteBE.Tfl_Fivig

            arrSqlParameter(4) = New SqlParameter()
            arrSqlParameter(4).ParameterName = "@Tfl_Ffvig"
            arrSqlParameter(4).SqlDbType = SqlDbType.Date
            arrSqlParameter(4).Direction = ParameterDirection.Input
            arrSqlParameter(4).Value = objTarifaFleteBE.Tfl_Ffinvig

            arrSqlParameter(5) = New SqlParameter()
            arrSqlParameter(5).ParameterName = "@Tfl_Tpag"
            arrSqlParameter(5).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(5).Size = 1
            arrSqlParameter(5).Direction = ParameterDirection.Input
            arrSqlParameter(5).Value = objTarifaFleteBE.Tfl_Tpag

            arrSqlParameter(6) = New SqlParameter()
            arrSqlParameter(6).ParameterName = "@Tfl_Csne"
            arrSqlParameter(6).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(6).Size = 6
            arrSqlParameter(6).Direction = ParameterDirection.Input
            arrSqlParameter(6).Value = objTarifaFleteBE.Tfl_Csne

            arrSqlParameter(7) = New SqlParameter()
            arrSqlParameter(7).ParameterName = "@Tfl_Emba"
            arrSqlParameter(7).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(7).Size = 6
            arrSqlParameter(7).Direction = ParameterDirection.Input
            arrSqlParameter(7).Value = objTarifaFleteBE.Tfl_Emba

            arrSqlParameter(8) = New SqlParameter()
            arrSqlParameter(8).ParameterName = "@Tfl_brocker"
            arrSqlParameter(8).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(8).Size = 6
            arrSqlParameter(8).Direction = ParameterDirection.Input
            arrSqlParameter(8).Value = objTarifaFleteBE.Tfl_brocker

            arrSqlParameter(9) = New SqlParameter()
            arrSqlParameter(9).ParameterName = "@Tfl_OpeLog"
            arrSqlParameter(9).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(9).Size = 6
            arrSqlParameter(9).Direction = ParameterDirection.Input
            arrSqlParameter(9).Value = objTarifaFleteBE.Tfl_OpeLog

            arrSqlParameter(10) = New SqlParameter()
            arrSqlParameter(10).ParameterName = "@Tfl_datosProd"
            arrSqlParameter(10).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(10).Size = 255
            arrSqlParameter(10).Direction = ParameterDirection.Input
            arrSqlParameter(10).Value = objTarifaFleteBE.Tfl_datosProd

            arrSqlParameter(11) = New SqlParameter()
            arrSqlParameter(11).ParameterName = "@Tfl_Tari"
            arrSqlParameter(11).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(11).Size = 10
            arrSqlParameter(11).Direction = ParameterDirection.Input
            arrSqlParameter(11).Value = objTarifaFleteBE.Tfl_Tari

            arrSqlParameter(12) = New SqlParameter()
            arrSqlParameter(12).ParameterName = "@Tfl_Umed"
            arrSqlParameter(12).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(12).Size = 3
            arrSqlParameter(12).Direction = ParameterDirection.Input
            arrSqlParameter(12).Value = objTarifaFleteBE.Tfl_Umed

            arrSqlParameter(13) = New SqlParameter()
            arrSqlParameter(13).ParameterName = "@Tfl_Pais"
            arrSqlParameter(13).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(13).Size = 3
            arrSqlParameter(13).Direction = ParameterDirection.Input
            arrSqlParameter(13).Value = objTarifaFleteBE.Tfl_Pais

            arrSqlParameter(14) = New SqlParameter()
            arrSqlParameter(14).ParameterName = "@Tfl_Puer"
            arrSqlParameter(14).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(14).Size = 3
            arrSqlParameter(14).Direction = ParameterDirection.Input
            arrSqlParameter(14).Value = objTarifaFleteBE.Tfl_Puer

            arrSqlParameter(15) = New SqlParameter()
            arrSqlParameter(15).ParameterName = "@Tfl_Mone"
            arrSqlParameter(15).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(15).Size = 3
            arrSqlParameter(15).Direction = ParameterDirection.Input
            arrSqlParameter(15).Value = objTarifaFleteBE.Tfl_Mone

            arrSqlParameter(16) = New SqlParameter()
            arrSqlParameter(16).ParameterName = "@Tfl_Mont"
            arrSqlParameter(16).SqlDbType = SqlDbType.Float
            arrSqlParameter(16).Direction = ParameterDirection.Input
            arrSqlParameter(16).Value = objTarifaFleteBE.Tfl_Mont

            arrSqlParameter(17) = New SqlParameter()
            arrSqlParameter(17).ParameterName = "@Tfl_Obse"
            arrSqlParameter(17).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(17).Size = 200
            arrSqlParameter(17).Direction = ParameterDirection.Input
            arrSqlParameter(17).Value = objTarifaFleteBE.Tfl_Obse

            arrSqlParameter(18) = New SqlParameter()
            arrSqlParameter(18).ParameterName = "@Tfl_ModTrans"
            arrSqlParameter(18).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(18).Size = 50
            arrSqlParameter(18).Direction = ParameterDirection.Input
            arrSqlParameter(18).Value = objTarifaFleteBE.Tfl_ModTrans

            arrSqlParameter(19) = New SqlParameter()
            arrSqlParameter(19).ParameterName = "@Tfl_PtoOperaciones"
            arrSqlParameter(19).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(19).Size = 50
            arrSqlParameter(19).Direction = ParameterDirection.Input
            arrSqlParameter(19).Value = objTarifaFleteBE.Tfl_PtoOper

            arrSqlParameter(20) = New SqlParameter()
            arrSqlParameter(20).ParameterName = "@Tfl_Servicio"
            arrSqlParameter(20).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(20).Size = 50
            arrSqlParameter(20).Direction = ParameterDirection.Input
            arrSqlParameter(20).Value = objTarifaFleteBE.Tfl_Servicio

            arrSqlParameter(21) = New SqlParameter()
            arrSqlParameter(21).ParameterName = "@Tfl_Ucre"
            arrSqlParameter(21).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(21).Size = 15
            arrSqlParameter(21).Direction = ParameterDirection.Input
            arrSqlParameter(21).Value = objTarifaFleteBE.Tfl_Ucre

            arrSqlParameter(22) = New SqlParameter()
            arrSqlParameter(22).ParameterName = "@Tfl_Umod"
            arrSqlParameter(22).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(22).Size = 15
            arrSqlParameter(22).Direction = ParameterDirection.Input
            arrSqlParameter(22).Value = objTarifaFleteBE.Tfl_Umod

            arrSqlParameter(23) = New SqlParameter()
            arrSqlParameter(23).ParameterName = "@Tfl_Est"
            arrSqlParameter(23).SqlDbType = SqlDbType.Char
            arrSqlParameter(23).Size = 1
            arrSqlParameter(23).Direction = ParameterDirection.Input
            arrSqlParameter(23).Value = objTarifaFleteBE.Tfl_Est


            Dim oDatos As New AccesoDatos()

            oDatos.EjecutaSP("SP_BlsTarifaFlete_Ins", bExito, sMensaje, arrSqlParameter)


            Return bExito

        Catch ex As Exception
            Throw
        End Try

    End Function



    Public Function ConsultarTarifaFlete(ByVal objTarifaFleteBE As TarifaFleteBE) As List(Of TarifaFleteBE)

        Dim sqlListar As String
        Dim objConsultaTarifaFlete As New List(Of TarifaFleteBE)
        Dim objTarifaBe As TarifaFleteBE = Nothing
        Dim arrSqlParameter(3) As SqlParameter
        Dim ds As DataSet
        Dim dt As DataTable

        Dim objDatos As New AccesoDatos()
        Dim blnExito As Boolean
        Dim strMensaje As String = String.Empty
        Dim intI As Integer = 0

        Try

            sqlListar = "SP_BlsTarifaFlete_List"

            arrSqlParameter(0) = New SqlParameter("@Cliente", System.Data.SqlDbType.VarChar)
            arrSqlParameter(0).Value = objTarifaFleteBE.Tfl_Csne
            arrSqlParameter(1) = New SqlParameter("@TipoMov", System.Data.SqlDbType.VarChar)
            arrSqlParameter(1).Value = objTarifaFleteBE.Tfl_Tmov
            arrSqlParameter(2) = New SqlParameter("@FecInicio", System.Data.SqlDbType.VarChar)
            arrSqlParameter(2).Value = objTarifaFleteBE.Tfl_Fivig
            arrSqlParameter(3) = New SqlParameter("@FecFin", System.Data.SqlDbType.VarChar)
            arrSqlParameter(3).Value = objTarifaFleteBE.Tfl_Ffinvig

            ds = objDatos.DevuelveDataSet(sqlListar, blnExito, strMensaje, arrSqlParameter)
            dt = ds.Tables(0)



            If dt.Rows.Count > 0 Then
                While intI < dt.Rows.Count
                    objTarifaBe = New TarifaFleteBE()

                    objTarifaBe.Tfl_Tipo = dt.Rows(intI).ItemArray(0).ToString
                    objTarifaBe.Tfl_Tmov = dt.Rows(intI).ItemArray(1).ToString
                    objTarifaBe.Tfl_Fivig = dt.Rows(intI).ItemArray(2).ToString
                    objTarifaBe.Tfl_Ffinvig = dt.Rows(intI).ItemArray(3).ToString
                    objTarifaBe.Tfl_Tpag = dt.Rows(intI).ItemArray(4).ToString
                    objTarifaBe.Tfl_Csne = dt.Rows(intI).ItemArray(5).ToString
                    objTarifaBe.Tfl_Emba = dt.Rows(intI).ItemArray(6).ToString
                    objTarifaBe.Tfl_brocker = dt.Rows(intI).ItemArray(7).ToString
                    objTarifaBe.Tfl_OpeLog = dt.Rows(intI).ItemArray(8).ToString
                    objTarifaBe.Tfl_datosProd = dt.Rows(intI).ItemArray(9).ToString


                    intI = intI + 1

                    objConsultaTarifaFlete.Add(objTarifaBe)
                End While
            End If

        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

        Return objConsultaTarifaFlete
    End Function

    Public Function EliminarTarifaFlete(ByVal objTarifaFleteBE As TarifaFleteBE, ByRef bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim arrSqlParameter(0) As SqlParameter

        Try

            arrSqlParameter(0) = New SqlParameter()
            arrSqlParameter(0).ParameterName = "@Cliente"
            arrSqlParameter(0).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(0).Size = 50
            arrSqlParameter(0).Direction = ParameterDirection.Input
            arrSqlParameter(0).Value = objTarifaFleteBE.Tfl_Csne

            Dim oDatos As New AccesoDatos()

            oDatos.EjecutaSP("SP_Tarifa_Flete_Eli", bExito, sMensaje, arrSqlParameter)

            Return bExito

        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

    End Function

    Public Function ModificarTarifaFlete(ByVal objTarifaFleteBE As TarifaFleteBE, ByRef bExito As Boolean, ByRef sMensaje As String) As Boolean

        Try

            Dim arrSqlParameter(23) As SqlParameter



            arrSqlParameter(0) = New SqlParameter()
            arrSqlParameter(0).ParameterName = "@Codigo"
            arrSqlParameter(0).SqlDbType = SqlDbType.Int
            arrSqlParameter(0).Direction = ParameterDirection.Input
            arrSqlParameter(0).Value = objTarifaFleteBE.Tfl_Codi

            arrSqlParameter(1) = New SqlParameter()
            arrSqlParameter(1).ParameterName = "@Tfl_Tipo"
            arrSqlParameter(1).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(1).Size = 10
            arrSqlParameter(1).Direction = ParameterDirection.Input
            arrSqlParameter(1).Value = objTarifaFleteBE.Tfl_Tipo

            arrSqlParameter(2) = New SqlParameter()
            arrSqlParameter(2).ParameterName = "@Tfl_Tmov"
            arrSqlParameter(2).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(2).Size = 1
            arrSqlParameter(2).Direction = ParameterDirection.Input
            arrSqlParameter(2).Value = objTarifaFleteBE.Tfl_Tmov

            arrSqlParameter(3) = New SqlParameter()
            arrSqlParameter(3).ParameterName = "@Tfl_Fivig"
            arrSqlParameter(3).SqlDbType = SqlDbType.Date
            arrSqlParameter(3).Direction = ParameterDirection.Input
            arrSqlParameter(3).Value = objTarifaFleteBE.Tfl_Fivig

            arrSqlParameter(4) = New SqlParameter()
            arrSqlParameter(4).ParameterName = "@Tfl_Ffvig"
            arrSqlParameter(4).SqlDbType = SqlDbType.Date
            arrSqlParameter(4).Direction = ParameterDirection.Input
            arrSqlParameter(4).Value = objTarifaFleteBE.Tfl_Ffinvig

            arrSqlParameter(5) = New SqlParameter()
            arrSqlParameter(5).ParameterName = "@Tfl_Tpag"
            arrSqlParameter(5).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(5).Size = 1
            arrSqlParameter(5).Direction = ParameterDirection.Input
            arrSqlParameter(5).Value = objTarifaFleteBE.Tfl_Tpag

            arrSqlParameter(6) = New SqlParameter()
            arrSqlParameter(6).ParameterName = "@Tfl_Csne"
            arrSqlParameter(6).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(6).Size = 6
            arrSqlParameter(6).Direction = ParameterDirection.Input
            arrSqlParameter(6).Value = objTarifaFleteBE.Tfl_Csne

            arrSqlParameter(7) = New SqlParameter()
            arrSqlParameter(7).ParameterName = "@Tfl_Emba"
            arrSqlParameter(7).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(7).Size = 6
            arrSqlParameter(7).Direction = ParameterDirection.Input
            arrSqlParameter(7).Value = objTarifaFleteBE.Tfl_Emba

            arrSqlParameter(8) = New SqlParameter()
            arrSqlParameter(8).ParameterName = "@Tfl_brocker"
            arrSqlParameter(8).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(8).Size = 6
            arrSqlParameter(8).Direction = ParameterDirection.Input
            arrSqlParameter(8).Value = objTarifaFleteBE.Tfl_brocker

            arrSqlParameter(9) = New SqlParameter()
            arrSqlParameter(9).ParameterName = "@Tfl_OpeLog"
            arrSqlParameter(9).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(9).Size = 6
            arrSqlParameter(9).Direction = ParameterDirection.Input
            arrSqlParameter(9).Value = objTarifaFleteBE.Tfl_OpeLog

            arrSqlParameter(10) = New SqlParameter()
            arrSqlParameter(10).ParameterName = "@Tfl_datosProd"
            arrSqlParameter(10).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(10).Size = 255
            arrSqlParameter(10).Direction = ParameterDirection.Input
            arrSqlParameter(10).Value = objTarifaFleteBE.Tfl_datosProd

            arrSqlParameter(11) = New SqlParameter()
            arrSqlParameter(11).ParameterName = "@Tfl_Tari"
            arrSqlParameter(11).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(11).Size = 10
            arrSqlParameter(11).Direction = ParameterDirection.Input
            arrSqlParameter(11).Value = objTarifaFleteBE.Tfl_Tari

            arrSqlParameter(12) = New SqlParameter()
            arrSqlParameter(12).ParameterName = "@Tfl_Umed"
            arrSqlParameter(12).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(12).Size = 3
            arrSqlParameter(12).Direction = ParameterDirection.Input
            arrSqlParameter(12).Value = objTarifaFleteBE.Tfl_Umed

            arrSqlParameter(13) = New SqlParameter()
            arrSqlParameter(13).ParameterName = "@Tfl_Pais"
            arrSqlParameter(13).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(13).Size = 3
            arrSqlParameter(13).Direction = ParameterDirection.Input
            arrSqlParameter(13).Value = objTarifaFleteBE.Tfl_Pais

            arrSqlParameter(14) = New SqlParameter()
            arrSqlParameter(14).ParameterName = "@Tfl_Puer"
            arrSqlParameter(14).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(14).Size = 3
            arrSqlParameter(14).Direction = ParameterDirection.Input
            arrSqlParameter(14).Value = objTarifaFleteBE.Tfl_Puer

            arrSqlParameter(15) = New SqlParameter()
            arrSqlParameter(15).ParameterName = "@Tfl_Mone"
            arrSqlParameter(15).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(15).Size = 3
            arrSqlParameter(15).Direction = ParameterDirection.Input
            arrSqlParameter(15).Value = objTarifaFleteBE.Tfl_Mone

            arrSqlParameter(16) = New SqlParameter()
            arrSqlParameter(16).ParameterName = "@Tfl_Mont"
            arrSqlParameter(16).SqlDbType = SqlDbType.Float
            arrSqlParameter(16).Direction = ParameterDirection.Input
            arrSqlParameter(16).Value = objTarifaFleteBE.Tfl_Mont

            arrSqlParameter(17) = New SqlParameter()
            arrSqlParameter(17).ParameterName = "@Tfl_Obse"
            arrSqlParameter(17).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(17).Size = 200
            arrSqlParameter(17).Direction = ParameterDirection.Input
            arrSqlParameter(17).Value = objTarifaFleteBE.Tfl_Obse

            arrSqlParameter(18) = New SqlParameter()
            arrSqlParameter(18).ParameterName = "@Tfl_ModTrans"
            arrSqlParameter(18).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(18).Size = 50
            arrSqlParameter(18).Direction = ParameterDirection.Input
            arrSqlParameter(18).Value = objTarifaFleteBE.Tfl_ModTrans

            arrSqlParameter(19) = New SqlParameter()
            arrSqlParameter(19).ParameterName = "@Tfl_PtoOperaciones"
            arrSqlParameter(19).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(19).Size = 50
            arrSqlParameter(19).Direction = ParameterDirection.Input
            arrSqlParameter(19).Value = objTarifaFleteBE.Tfl_PtoOper

            arrSqlParameter(20) = New SqlParameter()
            arrSqlParameter(20).ParameterName = "@Tfl_Servicio"
            arrSqlParameter(20).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(20).Size = 50
            arrSqlParameter(20).Direction = ParameterDirection.Input
            arrSqlParameter(20).Value = objTarifaFleteBE.Tfl_Servicio

            arrSqlParameter(21) = New SqlParameter()
            arrSqlParameter(21).ParameterName = "@Tfl_Ucre"
            arrSqlParameter(21).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(21).Size = 15
            arrSqlParameter(21).Direction = ParameterDirection.Input
            arrSqlParameter(21).Value = objTarifaFleteBE.Tfl_Ucre

            arrSqlParameter(22) = New SqlParameter()
            arrSqlParameter(22).ParameterName = "@Tfl_Umod"
            arrSqlParameter(22).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(22).Size = 15
            arrSqlParameter(22).Direction = ParameterDirection.Input
            arrSqlParameter(22).Value = objTarifaFleteBE.Tfl_Umod

            arrSqlParameter(23) = New SqlParameter()
            arrSqlParameter(23).ParameterName = "@Tfl_Est"
            arrSqlParameter(23).SqlDbType = SqlDbType.Char
            arrSqlParameter(23).Size = 1
            arrSqlParameter(23).Direction = ParameterDirection.Input
            arrSqlParameter(23).Value = objTarifaFleteBE.Tfl_Est

       


            Dim oDatos As New AccesoDatos()

            oDatos.EjecutaSP("SP_BlsTarifaFlete_Mod", bExito, sMensaje, arrSqlParameter)


            Return bExito

        Catch ex As Exception
            ex.Message.ToString()
        End Try

        Return bExito

    End Function

    Public Function ObtieneTarifaFlete(ByVal objTarifaFleteBE As TarifaFleteBE, ByRef bExito As Boolean, ByRef sMensaje As String, ByRef dt As DataTable) As List(Of TarifaFleteBE)


        Dim sqlListar As String
        Dim objConsultaTarifaFlete As New List(Of TarifaFleteBE)
        Dim objTarifaBe As TarifaFleteBE = Nothing
        Dim arrSqlParameter(0) As SqlParameter
        Dim ds As DataSet
        'Dim dt As DataTable

        Dim objDatos As New AccesoDatos()
        'Dim blnExito As Boolean
        Dim strMensaje As String = String.Empty
        Dim intI As Integer = 0

        Try

            sqlListar = "SP_BlsTarifaFlete_Obt"

            arrSqlParameter(0) = New SqlParameter("@Cliente", System.Data.SqlDbType.VarChar)
            arrSqlParameter(0).Value = objTarifaFleteBE.Tfl_Csne

            ds = objDatos.DevuelveDataSet(sqlListar, bExito, sMensaje, arrSqlParameter)
            dt = ds.Tables(0)



            If dt.Rows.Count > 0 Then
                While intI < dt.Rows.Count
                    objTarifaBe = New TarifaFleteBE()
                    objTarifaBe.Tfl_Codi = dt.Rows(intI).ItemArray(0).ToString
                    objTarifaBe.Tfl_Tipo = dt.Rows(intI).ItemArray(1).ToString
                    objTarifaBe.Tfl_Tmov = dt.Rows(intI).ItemArray(2).ToString
                    objTarifaBe.Tfl_Fivig = dt.Rows(intI).ItemArray(3).ToString
                    objTarifaBe.Tfl_Ffinvig = dt.Rows(intI).ItemArray(4).ToString
                    objTarifaBe.Tfl_Tpag = dt.Rows(intI).ItemArray(5).ToString
                    objTarifaBe.Tfl_Csne = dt.Rows(intI).ItemArray(6).ToString
                    objTarifaBe.Tfl_Emba = dt.Rows(intI).ItemArray(7).ToString
                    objTarifaBe.Tfl_brocker = dt.Rows(intI).ItemArray(8).ToString
                    objTarifaBe.Tfl_OpeLog = dt.Rows(intI).ItemArray(9).ToString
                    objTarifaBe.Tfl_datosProd = dt.Rows(intI).ItemArray(10).ToString
                    objTarifaBe.Tfl_Tari = dt.Rows(intI).ItemArray(11).ToString
                    objTarifaBe.Tfl_Umed = dt.Rows(intI).ItemArray(12).ToString
                    objTarifaBe.Tfl_CodPais = dt.Rows(intI).ItemArray(13).ToString
                    objTarifaBe.Tfl_CodPuer = dt.Rows(intI).ItemArray(14).ToString
                    objTarifaBe.Tfl_Mone = dt.Rows(intI).ItemArray(15).ToString
                    objTarifaBe.Tfl_Mont = dt.Rows(intI).ItemArray(16).ToString
                    objTarifaBe.Tfl_Est = dt.Rows(intI).ItemArray(17).ToString
                    objTarifaBe.Tfl_ModTrans = dt.Rows(intI).ItemArray(18).ToString
                    objTarifaBe.Tfl_PtoOper = dt.Rows(intI).ItemArray(19).ToString
                    objTarifaBe.Tfl_Servicio = dt.Rows(intI).ItemArray(20).ToString
                    objTarifaBe.Tfl_Obse = dt.Rows(intI).ItemArray(21).ToString
                    objTarifaBe.Tfl_DescCons = dt.Rows(intI).ItemArray(22).ToString
                    objTarifaBe.Tfl_DescEmb = dt.Rows(intI).ItemArray(23).ToString
                    objTarifaBe.Tfl_Pais = dt.Rows(intI).ItemArray(26).ToString
                    objTarifaBe.Tfl_Puer = dt.Rows(intI).ItemArray(27).ToString

                    intI = intI + 1

                    objConsultaTarifaFlete.Add(objTarifaBe)
                End While
            End If

        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

        Return objConsultaTarifaFlete


    End Function

    Public Function ValidarExisteTarifaFlete(ByVal objTarifaFleteBE As TarifaFleteBE, ByRef bExito As Boolean, ByRef sMensaje As String, ByRef dt As DataTable) As List(Of TarifaFleteBE)


        Dim sqlListar As String
        Dim objConsultaTarifaFlete As New List(Of TarifaFleteBE)
        Dim objTarifaBe As TarifaFleteBE = Nothing
        Dim arrSqlParameter(0) As SqlParameter
        Dim ds As DataSet
        'Dim dt As DataTable

        Dim objDatos As New AccesoDatos()
        'Dim blnExito As Boolean
        Dim strMensaje As String = String.Empty
        Dim intI As Integer = 0

        Try

            sqlListar = "SP_BlsTarifaFlete_Val"

            arrSqlParameter(0) = New SqlParameter("@codigo", System.Data.SqlDbType.Int)
            arrSqlParameter(0).Value = objTarifaFleteBE.Tfl_Codi

            ds = objDatos.DevuelveDataSet(sqlListar, bExito, sMensaje, arrSqlParameter)
            dt = ds.Tables(0)



            If dt.Rows.Count > 0 Then
                bExito = True
            Else
                bExito = False
            End If

        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

        Return objConsultaTarifaFlete


    End Function


End Class
